import http from '../http'
export type loginData = {
  clienttypecode: string
  username: string
  password: string
}
export type getAccountinfoData = {
  positionid: string
}
export type changePasswordData = {
  oldpassword: string
  newpassword: string
}

export type smscode = {
  mobile: string
}
export type smslogin = {
  mobile: string
  smscode: string
  clienttypecode: string
}

function loginApi(data: loginData) {
  return http.post('auth/login', data)
}
function getAccountinfo(data: getAccountinfoData) {
  return http.post('teapi/rolepermission/account/getaccountinfo', data)
}

function getCode(phone: string): Promise<{ num: number }> {
  return http.get('random/code', {
    params: {
      phone
    }
  })
}
function changePassword(data: changePasswordData) {
  return http.post('teapi/account/account/changepwd', data)
}
function setuseravatarData(data) {
  return http.post('teapi/dy-biz/893369323115122787/902820557983191121', data)
}

function getMenus() {
  return http.post('teapi/dy-biz/1871430946176241762/1871430946176241761', {})
}
function getsmscode(data: smscode) {
  return http.post('auth/smscode', data)
}
function smslogin(data: smslogin) {
  return http.post('auth/smslogin', data)
}
function getOpenidAndUnionid(data: any) {
  return http.post('teapi/dy-biz/1628579030947205218/1818895957669056611', data)
}


export default {
  loginApi,
  getCode,
  getAccountinfo,
  changePassword,
  setuseravatarData,
  getMenus,
  getsmscode,
  smslogin,
  getOpenidAndUnionid
}
